package com.boot.controller;

import com.boot.pojo.User;
import com.boot.service.IUserService;
import com.boot.service.IUserService2;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
@Tag(name="用户接口",description = "提供与用户接口说明")
public class UserController {
    @Autowired
    private IUserService2 userService;

    @GetMapping
    @Operation(summary = "查询所有用户")
    public List<User> getAllUsers(){
        return this.userService.list();
    }
    @GetMapping("/{id}")
    @Operation(summary = "根据id查询用户")
    @Parameters({
            @Parameter(name = "id",description = "用户id",in = ParameterIn.PATH)})
    public User getUserById(@PathVariable("id") Integer id){
        return this.userService.getById(id);
    }


}
